package com.bjpowernode.dataservice.mapper;

import com.bjpowernode.commons.model.BidInfo;
import com.bjpowernode.commons.model.BidRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface BidInfoMapper {
    @Select("select sum(a.bid_money) bidMoney,b.phone from b_bid_info a left join u_user b on a.uid=b.id GROUP BY uid ORDER BY bidMoney desc limit 3")
    List<Map> top3();

    @Insert("insert into b_bid_info values(" +
//            "#{id}," +
//            "#{prodId}," +
//            "#{uid}," +
//            "#{bidMoney}," +
//            "#{bidTime}," +
//            "#{bidStatus}" +
//            ")")
            "#{id}," +
            "#{prodId}," +
            "#{uid}," +
            "#{bidMoney}," +
            "#{bidTime}" +
            ")")
    void insert(BidInfo bidInfo);

    @Select(" select bid_money,bid_time,b.product_name from b_bid_info a" +
            " left join b_product_info b on a.prod_id=b.id " +
            " where uid=#{userId}")
    List<BidRecord> getRecords(Long userId);

    @Select("select * from b_bid_info where prod_id=#{id}")
    List<BidInfo> getBidInfoByProdId(Long id);
}
